<template>
  <el-row type="flex" justify="center">
    <el-col :xs="24" :sm="22" :md="20" :lg="18">
      <el-row  class="cardlist" :gutter="25">
        <el-col :xs="24" :sm="6" :md="6" :lg="4" v-for="(o, index) in userlist" :key="index">
          <el-card :body-style="{ padding: '0px'}" class="cardlistone">
            <div>
              <img @click="gotohomepage(o.id)" :src="o.headimg" class="image" v-if="o.headimg">
              <img @click="gotohomepage(o.id)" src="static/login.png" class="image" v-else>
              <div style="padding:14px;">
                <el-tooltip :content="o.remarks" placement="top">
                  <span class="time">{{o.remarks}}</span>
                </el-tooltip>
                <div class="bottom clearfix">
                  <el-button type="info" class="button" @click="setindexid(o.id)" size="mini">据为己有</el-button>
                </div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'square',
  data () {
    return {
      userlist: {}
    }
  },
  methods: {
    gotohomepage: function (id) {
      this.$router.push({name: 'homepage', params: {uid: id}})
    },
    setindexid: function (id) {
      this.H.SL('showindexuid', id)
      this.H.sendstore('showindexuid', id)
      this.H.success('设置成功，去首页看看吧！')
    }
  },
  mounted: function () {
    var that = this
    that.H.ajax('/home/index/getuserlist', {}, 'get', function (response) {
      if (response.success) {
        that.userlist = response.data
      }
    })
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .cardlist{
    padding:20px;
    height:650px;
    overflow-x: hidden;
    overflow-y: scroll;
  }
  .image{
    width: 100%;
    display: block;
    cursor: pointer;
  }
  .cardlistone{
    margin-bottom:20px;
    border:none;
    transition: .2s;
  }
  .cardlistone:hover{
    box-shadow: 0 0 8px 0 rgba(232,237,250,.6),0 2px 4px 0 rgba(232,237,250,.5);
  }

  .time {
    font-size: 13px;
    color: #999;
    display: block;
    height: 16px;
    overflow: hidden;
  }
  .clearfix:before,
  .clearfix:after {
      display: table;
      content: "";
  }
  
  .clearfix:after {
      clear: both
  }
  ::-webkit-scrollbar{width:8px;}
  /*::-webkit-scrollbar-track{background-color:#bee1eb;}*/
  ::-webkit-scrollbar-thumb{background-color:#00aff0;}
  ::-webkit-scrollbar-thumb:hover {background-color:#9c3}
  ::-webkit-scrollbar-thumb:active {background-color:#00aff0}
</style>
